home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / timer / sun4.md / timerIntersilInt.h < prev    next >
C/C++ Source or Header  |  1990-11-08  |  3KB  |  124 lines

  1. /*
  2.  * timerIntersilInt.h --
  3.  *
  4.  *    Types and constants for the Intersil ICM7170 real-time clock chip.
  5.  *
  6.  *    The definitions which define the bit fields for each register are
  7.  *    not fully explained in this file.  For a detailed explanation of the 
  8.  *    chip's functionality and the definitions listed below, see the
  9.  *    data sheet for the Intersil ICM7170 (order #301680-005, Dec. 1985).
  10.  *
  11.  * Copyright 1986 Regents of the University of California
  12.  * All rights reserved.
  13.  *
  14.  *
  15.  * $Header: /sprite/src/kernel/timer/sun3.md/RCS/timerIntersilInt.h,v 9.0 89/09/12 15:21:24 douglis Stable $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _DEVTIMERINT
  19. #define _DEVTIMERINT
  20.  
  21.  
  22.  
  23. /*
  24.  *-----------------------------------------------------------------
  25.  *
  26.  * Command Register bit assigments:  (p. 6)
  27.  *
  28.  *    The command register is 8 bits wide and is write-only. 
  29.  *    The 2 most significant bits (D7, D6) are not used.
  30.  *    One of the defines for each bit group must be used to compose
  31.  *    a command.
  32.  *
  33.  */
  34.  
  35. /* bits 0,1 (least significant bits) */
  36. #define FREQ_32K    0x00
  37. #define FREQ_1M        0x01
  38. #define FREQ_2M        0x02
  39. #define FREQ_4M        0x03
  40.  
  41. /* bit 2 */
  42. #define H12_HOUR_MODE    0x00
  43. #define H24_HOUR_MODE    0x04
  44.  
  45. /* bit 3 */
  46. #define STOP        0x00
  47. #define RUN        0x08
  48.  
  49. /* bit 4 */
  50. #define INTR_ENABLE    0x10
  51. #define INTR_DISABLE    0x00
  52.  
  53. /* bit 5 */
  54. #define NORMAL_MODE    0x00
  55. #define TEST_MODE    0x20
  56.  
  57. /*
  58.  * IntersilCommand macro is used to start or stop the clock and
  59.  * enable or disable interrupts from the chip. 
  60.  * The run argument can be one of RUN, STOP.
  61.  * The intr argument can be one of INTR_ENABLE, INTR_DISABLE.
  62.  */
  63.  
  64. #define IntersilCommand(run, intr)     \
  65.     (run | intr | FREQ_32K | H24_HOUR_MODE | NORMAL_MODE)
  66.  
  67.  
  68.  
  69. /*
  70.  *-----------------------------------------------------------------
  71.  *
  72.  *  Interrupt Mask and Status Register -- (pp. 6 and 7) 
  73.  *
  74.  *    
  75.  *    The interrupt register is 8 bits wide. Writing to the
  76.  *    register enables or disables interrupts from one or more  
  77.  *    periodic counters. Reading the register is used to determine 
  78.  *    which counter caused the interrupt.
  79.  *
  80.  *    There is an alarm register that can be used to cause an interrupt
  81.  *    when the time equals the value in the alarm register. This
  82.  *    feature is enabled with the ALARM_MASK.
  83.  *
  84.  */
  85.  
  86. #define ALARM_MASK    0x01
  87. #define S100TH_SEC_MASK    0x02
  88. #define S10TH_SEC_MASK    0x04
  89. #define SECOND_MASK    0x80
  90. #define MINUTE_MASK    0x10
  91. #define HOUR_MASK    0x20
  92. #define DAY_MASK    0x40
  93. #define INTR_PENDING_MASK    0x80
  94.  
  95.  
  96. /*
  97.  *-----------------------------------------------------------------
  98.  *
  99.  *  Intersil ICM7170 --
  100.  *
  101.  *    The chip's registers are composed of two sets of counters,
  102.  *    an interrupt mask/status register and a command register.
  103.  */
  104.  
  105. typedef struct {
  106.     unsigned char    hundredths;
  107.     unsigned char    hours;
  108.     unsigned char    minutes;
  109.     unsigned char    seconds;
  110.     unsigned char    month;
  111.     unsigned char    day;
  112.     unsigned char    year;
  113.     unsigned char    dayOfWeek;
  114. } IntersilCounters;
  115.  
  116. typedef struct {
  117.     IntersilCounters        counter;
  118.     IntersilCounters        alarm;
  119.     unsigned char        interruptReg;
  120.     unsigned char        commandReg;
  121. } TimerDevice;
  122.  
  123. #endif /* _DEVTIMERINT */
  124.